package part4createthread;

/**
 * @description: 代理模式总结:
 * 1. 真实对象和代理对象都要实现同一个接口。
 * 2. 代理对象要代理真实角色
 */
public class ProxyThreadDemo01 {

    public static void main(String[] args) {
        new Thread(() -> System.out.println("我是小A")).start();
        new WeddingCompany(new You()).HappyMarry();
    }

}

interface Marry {
    void HappyMarry();
}

class You implements Marry {

    @Override
    public void HappyMarry() {
        System.out.println("我结婚了");
    }
}

class WeddingCompany implements Marry {

    private Marry target;

    public WeddingCompany(Marry target) {
        this.target = target;
    }

    @Override
    public void HappyMarry() {
        before();
        this.target.HappyMarry();
        after();
    }

    private void before() {
        System.out.println("结婚之前，布置现场");
    }

    private void after() {
        System.out.println("结婚之后，收尾款");
    }
}